package com.geeksaga.domain;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.collections.FactoryUtils;
import org.apache.commons.collections.ListUtils;
import org.springframework.web.multipart.MultipartFile;

import com.geeksaga.annotation.PrintToString;
import com.geeksaga.common.util.HtmlUtil;
import com.geeksaga.common.util.Util;

/**
 * @author newbie
 * @since 0.1
 */
@SuppressWarnings("unchecked")
public class Spec extends BaseObject {

    private static final long serialVersionUID = -7541220201378663304L;
    
    public static enum CNT_TYPE { MEMO_PLUS_CNT, MEMO_MINUS_CNT, CODE_PLUS_CNT, CODE_MINUS_CNT, QUERY_PLUS_CNT, QUERY_MINUS_CNT, TAG_PLUS_CNT, TAG_MINUS_CNT };
    
    @PrintToString private String no;
    @PrintToString private String sid;
    @PrintToString private int partitionNo;
    @PrintToString private int categoryPartitionNo;
    @PrintToString private String categorySid;
    @PrintToString private String projectCode;
    @PrintToString private String depth;
    @PrintToString private String userSid;
    @PrintToString private String userPasswd;
    @PrintToString private String userNick;
    @PrintToString private String userIcon;
    @PrintToString private String userIp;
    @PrintToString private String userEmail;
    @PrintToString private String userHomepage;
    @PrintToString private String userCountry;
    @PrintToString private String specTitle;
    @PrintToString private String specDescription;
    @PrintToString private String codeCnt;
    @PrintToString private String queryCnt;
    @PrintToString private String memoCnt;
    @PrintToString private String fileCnt;
    @PrintToString private String tagCnt;
    @PrintToString private String tagSid;
    @PrintToString private String tagName;
    @PrintToString private String editYn;
    @PrintToString private String delYn;
    @PrintToString private String registDate;
    @PrintToString private String registTime;
    @PrintToString private String registTimestamp;
    @PrintToString private String modifyDate;
    @PrintToString private String modifyTime;
    @PrintToString private String modifyTimestamp;
    @PrintToString
    private List<SagaFile> fileList = new ArrayList<SagaFile>();
    @PrintToString
    private List<MultipartFile> file = new ArrayList<MultipartFile>();
    @PrintToString
    private List<SpecCode> codeList = ListUtils.lazyList(new ArrayList<SpecCode>(), FactoryUtils.instantiateFactory(SpecCode.class));
    @PrintToString
    private List<SpecQuery> queryList = ListUtils.lazyList(new ArrayList<SpecQuery>(), FactoryUtils.instantiateFactory(SpecQuery.class));
	@PrintToString
    private List<Memo> memoList = ListUtils.lazyList(new ArrayList<Memo>(), FactoryUtils.instantiateFactory(Memo.class));
    @PrintToString
    private List<Tag> tagList = ListUtils.lazyList(new ArrayList<Tag>(), FactoryUtils.instantiateFactory(Tag.class));

    public Spec() {}
    
    public Spec(String sid) {
    	this.sid = sid;
    }
    
    public Spec(String categorySid, String projectCode) {
        this.categorySid = categorySid;
        this.projectCode = projectCode;
    }
    
    public String getIndexingData() {
        StringBuilder sb = new StringBuilder();
        sb.append(getSpecTitle());
        sb.append("\r\n");
        sb.append(getUserNick());
        sb.append("\r\n");
        sb.append(HtmlUtil.removeTag(getSpecDescription()));
        
        Iterator<SagaFile> iterator = getFileList().iterator();
        
        while(iterator.hasNext()) {
            sb.append("\r\n");
            sb.append(iterator.next().getOriginalName());
        }
        
        return sb.toString();
    }
    
	public String getIp() {
		return Util.hideIp(userIp);
	}
    public String getNo() {
        return no;
    }
    public void setNo(String no) {
        this.no = no;
    }
    public String getSid() {
        return sid;
    }
    public void setSid(String sid) {
        this.sid = sid;
    }
    public int getPartitionNo() {
        return partitionNo;
    }
    public void setPartitionNo(int partitionNo) {
        this.partitionNo = partitionNo;
    }
    public int getCategoryPartitionNo() {
        return categoryPartitionNo;
    }
    public void setCategoryPartitionNo(int categoryPartitionNo) {
        this.categoryPartitionNo = categoryPartitionNo;
    }
    public String getCategorySid() {
        return categorySid;
    }
    public void setCategorySid(String categorySid) {
        this.categorySid = categorySid;
    }
    public String getProjectCode() {
        return projectCode;
    }
    public void setProjectCode(String projectCode) {
        this.projectCode = projectCode;
    }
    public String getDepth() {
        return depth;
    }
    public void setDepth(String depth) {
        this.depth = depth;
    }
    public String getUserSid() {
        return userSid;
    }
    public void setUserSid(String userSid) {
        this.userSid = userSid;
    }
    public String getUserPasswd() {
        return userPasswd;
    }
    public void setUserPasswd(String userPasswd) {
        this.userPasswd = userPasswd;
    }
    public String getUserNick() {
        return userNick;
    }
    public void setUserNick(String userNick) {
        this.userNick = userNick;
    }
    public String getUserIcon() {
        return userIcon;
    }
    public void setUserIcon(String userIcon) {
        this.userIcon = userIcon;
    }
    public String getUserIp() {
        return userIp;
    }
    public void setUserIp(String userIp) {
        this.userIp = userIp;
    }
    public String getUserEmail() {
        return userEmail;
    }
    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }
    public String getUserHomepage() {
        return userHomepage;
    }
    public void setUserHomepage(String userHomepage) {
        this.userHomepage = userHomepage;
    }
    public String getUserCountry() {
        return userCountry;
    }
    public void setUserCountry(String userCountry) {
        this.userCountry = userCountry;
    }
    public String getSpecTitle() {
        return specTitle;
    }
    public void setSpecTitle(String specTitle) {
        this.specTitle = specTitle;
    }
    public String getSpecDescription() {
        return specDescription;
    }
    public void setSpecDescription(String specDescription) {
        this.specDescription = specDescription;
    }
    public String getEditYn() {
        return editYn;
    }
    public void setEditYn(String editYn) {
        this.editYn = editYn;
    }
    public String getDelYn() {
        return delYn;
    }
    public void setDelYn(String delYn) {
        this.delYn = delYn;
    }
    public String getCodeCnt() {
        return codeCnt;
    }
    public void setCodeCnt(String codeCnt) {
        this.codeCnt = codeCnt;
    }
    public String getQueryCnt() {
        return queryCnt;
    }
    public void setQueryCnt(String queryCnt) {
        this.queryCnt = queryCnt;
    }
    public String getMemoCnt() {
        return memoCnt;
    }
    public void setMemoCnt(String memoCnt) {
        this.memoCnt = memoCnt;
    }
    public String getFileCnt() {
        return fileCnt;
    }
    public void setFileCnt(String fileCnt) {
        this.fileCnt = fileCnt;
    }
    public String getTagCnt() {
        return tagCnt;
    }
    public void setTagCnt(String tagCnt) {
        this.tagCnt = tagCnt;
    }    
    public String getTagSid() {
        return tagSid;
    }
    public void setTagSid(String tagSid) {
        this.tagSid = tagSid;
    }
    public String getTagName() {
        return tagName;
    }
    public void setTagName(String tagName) {
        this.tagName = tagName;
    }
    public String getRegistDate() {
        return registDate;
    }
    public void setRegistDate(String registDate) {
        this.registDate = registDate;
    }
    public String getRegistTime() {
        return registTime;
    }
    public void setRegistTime(String registTime) {
        this.registTime = registTime;
    }
    public String getRegistTimestamp() {
        return registTimestamp;
    }
    public void setRegistTimestamp(String registTimestamp) {
        this.registTimestamp = registTimestamp;
    }
    public String getModifyDate() {
        return modifyDate;
    }
    public void setModifyDate(String modifyDate) {
        this.modifyDate = modifyDate;
    }
    public String getModifyTime() {
        return modifyTime;
    }
    public void setModifyTime(String modifyTime) {
        this.modifyTime = modifyTime;
    }
    public String getModifyTimestamp() {
        return modifyTimestamp;
    }
    public void setModifyTimestamp(String modifyTimestamp) {
        this.modifyTimestamp = modifyTimestamp;
    }
    public List<SagaFile> getFileList() {
        return fileList;
    }
    public void setFileList(List<SagaFile> fileList) {
        this.fileList = fileList;
    }
    public List<MultipartFile> getFile() {
        return file;
    }
    public void setFile(List<MultipartFile> file) {
        this.file = file;
    }
    public List<SpecCode> getCodeList() {
		return codeList;
	}
	public void setCodeList(List<SpecCode> codeList) {
		this.codeList = codeList;
	}
	public List<SpecQuery> getQueryList() {
		return queryList;
	}
	public void setQueryList(List<SpecQuery> queryList) {
		this.queryList = queryList;
	}
    public List<Memo> getMemoList() {
        return memoList;
    }
    public void setMemoList(List<Memo> memoList) {
        this.memoList = memoList;
    }
    public List<Tag> getTagList() {
        return tagList;
    }
    public void setTagList(List<Tag> tagList) {
        this.tagList = tagList;
    }    
}